Jump to content

User:SoxBot V/Source

From Wikipedia, the free encyclopedia

The following is automatically generated by SoxBot V.


  • wikibot.classes.php is here.


Source to SoxBot V

[edit]
<?PHP

include '../Cluebot2/wikibot.classes.php';
include '../Cluebot2/cluebot5.config.php';
                
$wpq = new wikipediaquery;
$wpapi = new wikipediaapi;
$wpi = new wikipediaindex;
$http = new http;

$wpapi->login($user,$pass);
     
$wpi->forcepost('User:'.$user.'/Source',"The following is automatically generated by [[User:".$user."|]].\n\n\n\n* wikibot.classes.php is [[User:ClueBot/Source|here]].\n\n\n\n==Source to ".$user."==\n\n<pre>".htmlentities(file_get_contents(__FILE__))."</pre>\n\n\n\n~~~",'Automated source upload.'); /* Our source code, we force post this because this is *our* page, and it triggers the nobots. */
                
echo "Updating groups\n";
function numingroup($group) {
	$http = new http;
	$x = $http->get('http://en.wikipedia.org/w/api.php?action=query&list=allusers&augroup='.$group.'&aulimit=500&format=php');
	$x = unserialize($x);
	$y = $x['query']['allusers'];
	$num = array();
	foreach($y as $user) {
        array_push($num, $user['name']);
	}
	if ($x['query-continue']['allusers']['aufrom'] != "") {
		$zcont['query-continue']['allusers']['aufrom'] = $x['query-continue']['allusers']['aufrom'];
		while ($zcont['query-continue']['allusers']['aufrom'] != "") {
                $nextuser = urlencode($zcont['query-continue']['allusers']['aufrom']);
                $qurl = 'http://en.wikipedia.org/w/api.php?action=query&list=allusers&augroup='.$group.'&aulimit=500&format=php&aufrom=' . $nextuser;
                $aa = $http->get($qurl);
                $zcont = unserialize($aa);
                $zcont2 = $zcont[query][allusers];
                foreach($zcont2 as $user2) {
                        array_push($num, $user2[name]);
                }
        }
	}
	return count($num);
}

$crat = numingroup('bureaucrat');
$cu = numingroup('checkuser');
$os = numingroup('oversight');
$roll = numingroup('rollbacker');
$acc = numingroup('accountcreator');
$ipbe = numingroup('ipblock-exempt');
$numig = array('crats' => $crat, 'checkusers' => $cu, 'oversighters' => $os, 'rollbackers' => $roll, 'accountcreators' => $acc, 'ipblock-exempters' => $ipbe);

$text = $wpq->getpage('User:Soxred93/numingroup');
$default = '\{\{#switch\: \{\{\{1\|\}\}\} \n\|admin \= \{\{NUMBEROFADMINS\}\} \n\|bureaucrat \= (.*) \n\|checkuser \= (.*) \n\|oversight \= (.*) \n\|rollbacker \= (.*) \n\|accountcreator \= (.*) \n\|ipblock-exempt \= (.*) \n\|#default \= 0 \n\}\}';
preg_match('/'.$default.'/', $text, $m);
$new = "{{#switch: {{{1|}}} \n|admin = {{NUMBEROFADMINS}} \n|bureaucrat = ".$numig['crats']." \n|checkuser = ".$numig['checkusers']." \n|oversight = ".$numig['oversighters']." \n|rollbacker = ".$numig['rollbackers']." \n|accountcreator = ".$numig['accountcreators']." \n|ipblock-exempt = ".$numig['ipblock-exempters']." \n|#default = 0 \n}}";

$changes = null;
if ($numig['crats'] != $m[1]) {
	$changes .= $m[1]." crats to ".$numig['crats'].", ";
}
if ($numig['checkusers'] != $m[2]) {
	$changes .= $m[2]." checkusers to ".$numig['checkusers'].", ";
}
if ($numig['oversighters'] != $m[3]) {
	$changes .= $m[3]." oversighters to ".$numig['oversighters'].", ";
}
if ($numig['rollbackers'] != $m[4]) {
	$changes .= $m[4]." rollbackers to ".$numig['rollbackers'].", ";
}
if ($numig['accountcreators'] != $m[5]) {
	$changes .= $m[5]." accountcreators to ".$numig['accountcreators'].", ";
}
if ($numig['ipblock-exempters'] != $m[6]) {
	$changes .= $m[6]." ipblock-exempters to ".$numig['ipblock-exempters'].", ";
}
$summary = "Changing ".$changes."a BOT EDIT.";

$wpi->post('User:Soxred93/numingroup', $new, $summary);

?>


SoxBot V (talk)